package com.gk.javaservice.service.impl;

import com.gk.javaservice.dao.AdminUsersDao;
import com.gk.javaservice.po.AdminUsers;
import com.gk.javaservice.service.AdminUsersService;
import com.gk.javaservice.util.time.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminUsersServiceImpl implements AdminUsersService {

    @Autowired
    private AdminUsersDao baseDao;
    @Override
    public void add(AdminUsers adminUsers) {
        String getTime = TimeUtil.dateFormat();
        adminUsers.setCreated_at(getTime);
        adminUsers.setUpdated_at(getTime);
        baseDao.add(adminUsers);
    }

    @Override
    public Integer update(AdminUsers adminUsers) {
        String getTime = TimeUtil.dateFormat();
//        adminUsers.setCreated_at(getTime);
        adminUsers.setUpdated_at(getTime);
        return baseDao.update(adminUsers);
    }

    @Override
    public Integer delete(Object id) {
        return baseDao.delete(id);
    }

    @Override
    public List<AdminUsers> hasAll() {
        return baseDao.hasAll();
    }

    @Override
    public AdminUsers hasById(Object id) {
        return baseDao.hasById(id);
    }

    @Override
    public AdminUsers findByName(String name) {
        return baseDao.findByName(name);
    }

    @Override
    public List<AdminUsers> searchByDep(String id) {
        return baseDao.searchByDep(id);
    }

    @Override
    public int countUserByName(String name) {
        return baseDao.countUserByName(name);
    }

    @Override
    public AdminUsers login(AdminUsers u) {
        return baseDao.login(u);
    }

    @Override
    public AdminUsers autoLogin(AdminUsers u) {
        return baseDao.autoLogin(u);
    }

    @Override
    public List<AdminUsers> hasAllToPage(int offset, int limit,String searchMsg) {
        return baseDao.hasAllToPage(offset,limit,searchMsg);
    }

    @Override
    public int queryTotal(String searchMsg) {
        return baseDao.queryTotal(searchMsg);
    }
}
